<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Personnel_list extends Page
{
       public $JTEmpList = null;
       public $JTJavaScript1 = null;
       public $hiddenEmp = null;
       public $imgAdd = null;
       public $JTSiteTheme1 = null;
       public $Image1 = null;
       function imgAddJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new.png"
       <?php

       }

       function imgAddJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new_blue.png"
       <?php

       }

       function Personnel_listCreate($sender, $params)
       {
       $this->imgAdd->setLink('personnel_create.php');


       }


       function JTEmpListShow($sender, $params)
       {
       $query1 = "select * from employee_tbl where company_id='".$_SESSION['company_id']."' order by terminate ASC,job_title ASC";
       $result = mysql_query($query1)or die(mysql_error());

        $arr = array();
        while($row = mysql_fetch_array($result))
          {

            $emp = $row['autoid'];
            $title = $row['job_title'];
            $terminated = $row['terminate'];
            $veh_op = $row['veh_op'];


            //<a href=personnel_driving_list.php?emp=".$emp."><img src='image/dr_history.png' title='incident report' no border></a>


            if($veh_op==1)
            {
            $tools = "<a href=emp_license.php?emp=".$emp."><img src='image/dr_license.png' title='license' no border></a>
            <a href=emp_certification_list.php?emp=".$emp."><img src='image/dr_certification.png' title='certification list' no border></a>
            <img onclick=js_deletePersonnel('".$emp."'); src='image/delete.png' title='delete' style='cursor:pointer'>";
            }

            if($veh_op==0)
            {
            $tools = "<img onclick=js_deletePersonnel('".$emp."'); src='image/delete.png' title='delete' style='cursor:pointer'>";
            }

            if($terminated==1)
            {
            $color = "Silver";
            }

            if($terminated==0)
            {
            $color = "Black";
            }

            $photo = "<div align='center'><a href=personnel_edit.php?emp=".$emp."><img src='".$row['photo']."' height='50px' width='50px'></a></div>";

            $arr[] = array(
                        'Photo' => "<p style='color:".$color."'>".$photo."</p>",
                        'Emp ID' => "<p style='color:".$color."'>".$row['emp_id']."</p>",
                        'Name' => "<p style='color:".$color."'>".$row['lname'].','.$row['fname']."</p>",
                        'Job Title' => "<p style='color:".$color."'>".$row['job_title']."</p>",
                        'Contact Num' => "<p style='color:".$color."'>".$row['phone_num']."</p>",
                        'Department' => "<p style='color:".$color."'>".$row['department']."</p>",
                        'Tools' => $tools
                        );


          }

            $this->JTEmpList->setCellData($arr);



       }

}

global $application;

global $Personnel_list;

//Creates the form
$Personnel_list=new Personnel_list($application);

//Read from resource file
$Personnel_list->loadResource(__FILE__);

//Shows the form
$Personnel_list->show();

?>